/**
 * Created by YW on 2017/12/12.
 */
function p(e) {console.log(e);}
(function(window) {
    var theUA = window.navigator.userAgent.toLowerCase();
    if ((theUA.match(/msie\s\d+/) && theUA.match(/msie\s\d+/)[0]) || (theUA.match(/trident\s?\d+/) && theUA.match(/trident\s?\d+/)[0])) {
        var ieVersion = theUA.match(/msie\s\d+/)[0].match(/\d+/)[0] || theUA.match(/trident\s?\d+/)[0];
        if (ieVersion < 9) {
            var str = "你的浏览器版本太陈旧了,已经和时代脱轨了 :(";
            var str2 = "推荐使用:<a href='http://browser.qq.com/' target='_blank' style='color:blue;'>QQ浏览器</a>,"
                + "<a href='http://chrome.360.cn/' target='_blank' style='color:blue;'>360浏览器</a>," + "<a href='https://liulanqi.baidu.com/' target='_blank' style='color:blue;'>百度浏览器</a>,"
                + "等现代浏览器";
            document.writeln("<pre style='text-align:center;color:#fff;background-color:#0099CC;line-height:40px;height:100%;border:0;position:fixed;top:0;left:0;width:100%;z-index:1234'>" +
                "<h2 style='padding-top:200px;margin:0'><strong>" + str + "<br/></strong></h2><h2>" +
                str2 + "</h2><h2 style='margin:0'><strong>如果你的使用的是双核浏览器,请切换到极速模式访问<br/></strong></h2></pre>");
            document.execCommand("Stop");
        };
    }
})(window);
$.fn.extend({
    animateCss: function (animationName, callback) {
        var animationEnd = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';
        this.addClass('animated ' + animationName).one(animationEnd, function() {
            $(this).removeClass('animated ' + animationName);
            if (callback) {
                callback();
            }
        });
        return this;
    }
});
//top-bar
$(function () {
    $("#jobs-btn").hover(function(){
        $(this).html('招聘');
    },function(){
        $(this).html('JOBS');
    });
    $("#contact-btn").hover(function(){
        $(this).html('联系我们');
    },function(){
        $(this).html('CONTACT US');
    });
    $("#qrcode-btn").hover(function(){
        $(this).children('.show-qrcode').show();
    },function(){
        $(this).children('.show-qrcode').hide();
    });
    //导航过度效果
    var $liCur = $(".nav .menu .cur");
    var curP = 0;
    var curW = 0;
    if($liCur.length != 0){
        curP = $liCur.position().left+56;
        curW = $liCur.width();
    }
    var $slider = $(".nav .curBg");
    var $navBox = $(".nav .menu");
    var $targetEle = $(".nav .menu a");
    var $navSonMenu = $(".nav .son-menu");
    var delay;
    $slider.css({
        "left":curP,
        "width":curW
    });
    $(".nav .son-menu .con").css("margin-left",$(".nav .menu a:first-child").position().left+56+280+1);
    $targetEle.mouseenter(function () {
        var _width = $(this).width(),
            posL = $(this).position().left+56;
        if($liCur.length == 0){
            $slider.css({
                "left":posL,
                "width":_width
            });
        }else{
            $slider.stop(true, true).animate({
                "left":posL,
                "width":_width
            }, "fast");
        }
        $navSonMenu.stop().slideDown(200);
        $navSonMenu.find('.con').hide();
        $navSonMenu.find('.isid'+$(this).attr('isid')).show();
        clearTimeout(delay);
    });
    $navBox.mouseleave(function (cur, wid) {
        delay = setTimeout(function(){
            //$navSonMenu.stop().slideUp(200);
        }, 1000);
    });
    $navSonMenu.mouseenter(function () {
        //$navSonMenu.stop().show();
        clearTimeout(delay);
    });
    $navSonMenu.mouseleave(function () {
        cur = curP;
        wid = curW;
        if($liCur.length == 0){
            $slider.css({
                "left":0,
                "width":0
            });
        }else{
            $slider.stop(true, true).animate({
                "left":cur,
                "width":wid
            }, "fast");
        }
        //$navSonMenu.stop().slideUp(200);
    });
    //锚链接平滑滚动
    $('a[href*=#],area[href*=#]').click(function() {
        if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
            var $target = $(this.hash);
            $target = $target.length && $target || $('[name=' + this.hash.slice(1) + ']');
            if ($target.length) {
                var targetOffset = $target.offset().top;
                $('html,body').animate({
                    scrollTop: targetOffset
                },1000);
                return false;
            }
        }
    });
    //底部锚点点击
    $('#back-top').click(function () {
        $(this).animateCss('slideOutUp');
    });
    //分享按钮切换tub
    $(".icon-share-weibo").on("mouseenter",function(){
        $(this).attr("src",ROOT+"/static/home/images/icon-weibo-hover.png")
    }).on("mouseleave",function(){
        $(this).attr("src",ROOT+"/static/home/images/icon-weibo.png")
    });
   	$(".icon-share-weixin").on("mouseenter",function(){
        $(this).attr("src",ROOT+"/static/home/images/icon-weixin-hover.png");
        $('.weixin_gzh_qrcode').show();
    }).on("mouseleave",function(){
        $(this).attr("src",ROOT+"/static/home/images/icon-weixin.png");
        $('.weixin_gzh_qrcode').hide();
    });
});
function open_video(url) {
    layer.open({
        type: 2,
        title: false,
        area: ['80%', '80%'],
        shade: 0.8,
        closeBtn: 1,
        shadeClose: true,
        content: url
    });
}